#include <tinx/syscall.h>
#include <tinx/printf.h>
#include <tinx/fs.h>

int main()
{
    fd_t fd = open(".", O_RDONLY, 0755);

    stat_t statbuf;
    fstat(fd, &statbuf);

    char buf[statbuf.size];

    int count = getdents(fd, buf, statbuf.size);
    dentry_t *ptr = (dentry_t *)buf;

    for (int i = 0; i < count; i += ptr->length, ptr = (dentry_t *)((u32)ptr + ptr->length))
    {
        printf("%s ", ptr->name);
    }

    printf("\n");

    close(fd);

    return EOK;
}